/*
 * @Author: your name
 * @Date: 2021-10-07 19:45:36
 * @LastEditTime: 2021-10-07 19:50:37
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \common-vue\src\plugins\createOutComponent.js
 */
const createOutCpPlugin = {
  install: (Vue, options) => {
    const { Component } = options
    const vm = new Vue({
      render: h => {
        return h(Component, { props: options })
      }
    })
    // 挂载 获取dom
    vm.$mount()
    document.body.appendChild(vm.$el)
    // 获取组件实例
    const comp = vm.$children[0]

    comp.remove = () => {
      document.body.removeChild(vm.$el)
      vm.$destroy()
    }
  }
}

export default createOutCpPlugin
